
<template>
 <section class="oa-form__table">
    <h5>{{ approve.name }}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>
          {{ approve.name }}
          <span v-if="approve && approve.code">{{ approve.code }}</span>
        </td>
      </tr>
      <tr>
        <td>流程名称</td>  
        <td>
          <span v-if="$route.query.from == 'new'">新建{{ approve.name }}</span>
          <span v-else>
            {{ approve.approve_name }}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{ approve.name }}</span>
      <span v-else>
        {{ approve.approve_name }}
      </span>
    </h3>
   <table class="achievement__tab">
    <tr class="border_0">
      <td width="200">考核周期:</td>
      <td width="200">
        <el-date-picker
          value-format="yyyy-MM-dd"
          type="date"
          v-model="applyTime"
          :disabled="$route.query.from !== 'new'"
          placeholder="考核周期">
        </el-date-picker>
      </td>
      <td width="200">部门:</td>
      <td>
        <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
          <el-option
            v-for="item in departments"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </td>
      <td>姓名:</td>
      <td>
        <el-select v-model="value" style="width:60%" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
          <el-option
            v-for="item in staff"
            :key="item.value"
            :label="item.label"
            :value="item">
          </el-option>
        </el-select>
      </td>
      <!-- <td>岗位:</td> -->
      <td>职位:</td>
      <td><el-input v-model="gangwei" :disabled="$route.query.from !== 'new'" placeholder="职位"/></td>
      <td></td>
    </tr>
    <tr>
      <td colspan="2">KPI</td>
      <td>指标定义</td>
      <td>权重</td>
      <td>数据提供</td>
      <td>计划完成量</td>
      <td>实际完成量</td>
      <td>超额完成量</td>
      <td>评估得分</td>
      <!-- <td>扣分事项说明</td> -->
    </tr>
    <tr>
      <td>考核指标</td>
      <td>新客户开发</td>
      <td>每月增加60个新客户</td>
      <td>30%</td>
      <td>直属上级</td>
      <td><el-input v-model="obj.a797" :disabled="obj.a797Flag" /></td>
      <td><el-input v-model="obj.a801" :disabled="obj.a801Flag" /></td>
      <td><el-input v-model="b1" disabled/></td>
      <td><el-input v-model="obj.a808" :disabled="obj.a808Flag" /></td>
      <!-- <td>&nbsp;</td> -->
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>约见客户</td>
      <td>每月10个</td>
      <td>30%</td>
      <td>直属上级</td>
      <td><el-input v-model="obj.a798" :disabled="obj.a798Flag" /></td>
      <td><el-input v-model="obj.a802" :disabled="obj.a802Flag" /></td>
      <td><el-input v-model="b2" disabled/></td>
      <td><el-input v-model="obj.a809" :disabled="obj.a809Flag" /></td>
      <!-- <td>&nbsp;</td> -->
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>报备客户</td>
      <td>每月至少增加4个准意向客户</td>
      <td>30%</td>
      <td>直属上级</td>
      <td><el-input v-model="obj.a799" :disabled="obj.a799Flag" /></td>
      <td><el-input v-model="obj.a803" :disabled="obj.a803Flag" /></td>
      <td><el-input v-model="b3" disabled/></td>
      <td><el-input v-model="obj.a810" :disabled="obj.a810Flag" /></td>
      <!-- <td>&nbsp;</td> -->
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>总业绩(万元)</td>
      <td>当月总销售业绩金额</td>
      <td>30%</td>
      <td>财务部</td>
      <td><el-input v-model="obj.a800" :disabled="obj.a800Flag" /></td>
      <td><el-input v-model="obj.a815" :disabled="obj.a815Flag" /></td>
      <td><el-input v-model="b4" disabled/></td>
      <td><el-input v-model="obj.a811" :disabled="obj.a811Flag" /></td>
      <!-- <td>&nbsp;</td> -->
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>周报</td>
      <td>
        每周向部门]提交一份周报
        &nbsp;
      </td>
      <td>&nbsp;</td>
      <td>直属上级</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><el-input v-model="obj.a812" :disabled="obj.a812Flag" /></td>
      <!-- <td>&nbsp;</td> -->
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>遵守公司规章制度</td>
      <td>
        对公司制度及企业文化的理解和执行，
        履行本部门工作中的行为表现
      </td>
      <td>5%</td>
      <td>直属上级</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><el-input v-model="obj.a813" :disabled="obj.a813Flag" /></td>
      <!-- <td>&nbsp;</td> -->
    </tr>
    <tr>
      <td colspan="2"></td>
      <td colspan="3"></td>
      <td colspan="4">综合考核率:{{myScore}}</td>
    </tr>
    <tr>
      <td colspan="10">
        本人已认真阅读并认可本绩效考核评定表，同意遵循并执行本绩效考核评定表。
        <p>
          1、月度业绩目标根据部门总经理提交的基数，计算方式：每月实际的销售业绩÷目标值=X,根据X符合的相对应条件：
          ①X＜60%，得50%；②60%≤X＜75%,得65%；③75%≤X＜90%,得75%；④X>90%，得100%
          绩效考核分=（1-扣减分）×权重（70%）。
        </p>
      </td>
    </tr>
  </table>
    <history :process="process"></history>
    <files></files>
  </section>
</template>
<script>
import mixin from '@/mixins/index.js'
import history from '../service/components/process'
import files from '../service/components/files'
import { sum } from '@/utils/domUtils.js'
const obj = {}
for (let i = 795; i <= 815; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: '',
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    },
    b1 () {
      const num = this.obj.a801 - this.obj.a797
      return num
    },
    b2 () {
      const num = this.obj.a802 - this.obj.a798
      return num
    },
    b3 () {
      const num = this.obj.a803 - this.obj.a799
      return num
    },
    b4 () {
      const num = this.obj.a815 - this.obj.a800
      return num
    },
    myScore () {
      const result = []
      for (let i = 808; i <= 811; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    }
  },
  watch: {
    addDofield () {
      this.addDofieldRender()
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
    })
  },
  methods: {
  }
}
</script>
